package com.mygdx.game.stage;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.InputListener;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.mygdx.game.Constants;

/**
 * MenuStage
 * Created by 80002023 on 2016/8/3.
 */
public class MenuStage extends Stage {
    Texture texture;
    TextureRegion startRegion;
    Image startImage;
    Image newGameBtn;
    TextureRegion newGameRegion;

    public MenuStage() {
        super();

        texture = new Texture(Gdx.files.internal("data/start.png"));
        startRegion = new TextureRegion(texture, 0, 0, 800, 480);
        startImage = new Image(startRegion);
        startImage.setSize(480, 320);

        newGameRegion = new TextureRegion(texture, 924, 0, 100, 50);
        newGameBtn = new Image(newGameRegion);
        newGameBtn.setPosition(40, 230);

        this.addActor(startImage);
        this.addActor(newGameBtn);

        newGameBtn.addListener(new InputListener() {

            @Override
            public boolean touchDown(InputEvent event, float x, float y,
                                     int pointer, int button) {
                Constants.stageFlag = Constants.gameStageOn;

                return true;
            }
        });
    }
}
